package com.linkit.main.widget;

import android.content.Context;
import android.graphics.Bitmap;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;

import com.linkit.main.R;

/**
 * ndluc : Đây là 1 widget gồm 2 trường: icon và progressbar. mục đích hiện thị khi load ảnh từ url
 */
public class ExtendedImageView extends RelativeLayout {

	private ProgressBar progressBar;
	private ImageView imageView;
	private ImageView playIcon;

	public ExtendedImageView(Context context, AttributeSet attrs) {
		super(context, attrs);
		RelativeLayout.inflate(context, R.layout.extended_image_view, this);

		progressBar = (ProgressBar) findViewById(R.id.extended_image_view_processbar);
		imageView = (ImageView) findViewById(R.id.extended_image_view_icon);
		imageView.setVisibility(View.GONE);
		playIcon = (ImageView) findViewById(R.id.extended_image_play_video);
		playIcon.setVisibility(View.GONE);
	}

	public void setImage(Bitmap bitmap) {
		imageView.setImageBitmap(bitmap);
		progressBar.setVisibility(View.GONE);
		imageView.setVisibility(View.VISIBLE);
		playIcon.setVisibility(View.GONE);
	}
	
	public void setVideoImage(Bitmap bitmap) {
		progressBar.setVisibility(View.GONE);
		imageView.setImageBitmap(bitmap);
		imageView.setVisibility(View.VISIBLE);
		playIcon.setVisibility(View.VISIBLE);
		
	}
}
